<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    // return view('welcome');
    // return [1,2,3];
    return view('home.greeting', ['name' => '学院君']);
});

Route::get('hello',function(){
    return 'Hello, Welcome to Blog.dev.cc';
});

// Route::get('/user', 'UsersController@index');
// Route::get('/user/{name}', function($name){
//     return $name;
//     // return 'UsersController@index';
// })->where('id','[A-Za-z]+');
Route::get('/user/{id}', function($id){
        return $id;
        // return 'UsersController@index';
})->where('id','[0-9]+');
Route::get('/user/profile',function(){
    return 'Url: '.route('profile');
})->name('profile');

Route::match(['get','post'],'foo',function(){
    return 'This is post request';
});

Route::get('form', function(){
    return '<form method="POST", action="/foo">'.csrf_field().' <button type="submit"> 提交 </botton></from>';
});

// Route::namespace('User')->group(function(){
//     return __METHOD__;
// });
Route::get('user/user/{id}', 'User\UsersController@show');
Route::resource('posts', 'PostController');

Route::post('user/user/update', 'User\UsersController@update');

Route::get('cookie/add',function(){
    $minute = 60 * 10;
    return response('欢迎来访')->cookie('name', '学院君', $minute);
});

Route::get('cookie/get', function(\Illuminate\Http\Request $request){
    $cookie = $request->cookie('name');
    dd($cookie);
});

Route::get('cookie/response', function () {
    // return redirect('home/dashboard');

    return response('Hello World', 400)
        ->header('Content-Type', 'text/plain')
        ->cookie('name', 'value', 10);
});

Route::get('download/response', function() {
    return response()->download(storage_path('app/photo/test.jpg'), '测试图片.jpg');
});

// Route::get('/', function(){
//     return view()->first(['customer.admin','admin'],['data'=>'bbbbbbbbbbbbbb']);
// });
Route::get('profile', function(){
    return view('profile');
});
